$(document).ajaxSend(function (e, xhr, opt) {
    var user_token = localStorage.getItem("user_token");
    xhr.setRequestHeader("user_token", user_token);
});

function getUserInfo(){
    $.ajax({
        type: "get",
        url: "userController/getUserInfo",
        success:function(result){
            if(result.code === 200 && result.data != null){
                console.log(result)
                $(".left .card h3").text(result.data.userName);
                $(".left .card a").attr("href", result.data.githubUrl);
            }
        },
        error:function (err){
            if(err.code === -1){
                alert("该用户不存在");
            } else {
                location.href = "blog_login.html";
            }
        }
    });
}

function logout(){
    localStorage.removeItem("user_token");
    location.href = "blog_login.html";
}